<?php

require_once("db/DAO/CategoryDAO.php");
require_once ("db/DAO/ProductDAO.php");
require_once ("model/Category.php");
require_once ("model/Product.php");

//+dalsi DAO tridy

/**
 * Fasada/y predstavuji jen sjednoceni operaci nad objekty
 * a pristup k nim, tadle fasada napr. poskytuje veskere
 * nacitaci operace objektu v databazi..
 */

class ReadFacade {
	
	private static $instance;
	
	private $categoryDAO;
	private $productDAO;
	
	private function __construct() {
		$this->categoryDAO = new CategoryDAO();
		$this->productDAO = new ProductDAO();
	}

	private function __clone() {
		//overide clone metody, kvuli tomu aby se nedala udelat jina instance
	
	
	}
	
	
	public static function getInstance() {
		if (!self :: $instance instanceof self) {
			self :: $instance = new self;
		}
		return self :: $instance;
	}
	
	
	public function loadCategory($id){
		return $this->categoryDAO->loadCategory($id);	
	}
	
	public function loadCategoryByParent($parentId){
		return $this->categoryDAO->loadCategoryByParent($parentId);
	}
	
	public function loadProduct($id){
		return $this->productDAO->loadProduct($id);
	}
	
	public function loadProductListByCategory($cat){
		return $this->productDAO->loadProductListByIdCategory($cat);
	}
	
	public function loadProductListByCategoryLimit($cat, $od, $do){
		return $this->productDAO->loadProductListByIdCategoryLimit($cat,$od,$do);
	}
	
	public function getProductCount($id){
		return $this->productDAO->getCountOfProducts($id);	
	}
	
	//+dalsi loadMetody ruznych DAO trid


}
